import java.util.*;
import java.io.*;
public class test {
    public static PrintWriter pr = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
    public static Read in = new Read();
    // 蓝桥杯 能选取元素的最多个数(⭐⭐)
    public static void main(String[] args) throws IOException {
        int n = in.nextInt();
        int[] arr = new int[n];
        HashMap<Integer,Integer> map = new HashMap<>();
        int nosum = 0;
        int max = 0;
        for(int i = 0;i < n;i++) {
            arr[i] = in.nextInt();
            max = Math.max(max, arr[i]);
        }
        //Arrays.sort(arr);
        //除了最大值只能有一个,其他都可以为两个
        int maxnum = 0;
        for(int i = 0;i < n;i++) {
            if(arr[i] == max) {
                if(maxnum == 1) {
                    nosum++;
                    continue;
                }
                maxnum++;
            }
            if(map.getOrDefault(arr[i], 0) < 2) {//1 1 4 7 5 5 8 8 9 2 6 3
                map.put(arr[i],map.getOrDefault(arr[i], 0) + 1);
            }else {
                nosum++;
            }
        }
        System.out.println(n - nosum);
    }
    // 蓝桥杯 谭谭的树上研究(⭐⭐⭐)
    public static int[] dist1;
    public static int[] dist2;
    public static ArrayList<Integer>[] list;
    public static int l;
    public static int r;
    public static void main2(String[] args) throws IOException{
        int n = in.nextInt();
        int k = in.nextInt();
        dist1 = new int[n + 1];
        dist2 = new int[n + 1];
        list = new ArrayList[n + 1];
        for(int i = 1;i <= n;i++) {
            list[i] = new ArrayList<Integer>();
        }
        for(int i = 1;i < n;i++) {
            int start = in.nextInt();
            int end = in.nextInt();
            list[start].add(end);
            list[end].add(start);
        }
        l = in.nextInt();Arrays.fill(dist1, -1);
        r = in.nextInt();Arrays.fill(dist2, -1);
        dist1[l] = 0;
        dist2[r] = 0;
        dfs(l, dist1);
        dfs(r, dist2);
        long sum = 0;
        for (int i = 1; i <= n; i++) {
            sum += Math.min(dist1[i], dist2[i]);
        }
        System.out.println(sum * k);
    }
    public static void dfs(int start,int[] dist) {
        if(list[start].size() == 0) {
            return;
        }
        ArrayList<Integer> path = list[start];
        for(int i = 0;i < path.size();i++) {
            int index = path.get(i);
            if(dist[index] != -1) continue;
            dist[index] = dist[start] + 1;
            dfs(index, dist);
        }
    }
    // 蓝桥杯 组合0(⭐⭐)
    public static void main3(String[] args) {
        Scanner scanner=new Scanner(System.in);
        int t=scanner.nextInt();
        while (t-->0) {
            int n=scanner.nextInt();
            int m=scanner.nextInt();
            System.out.println(get0(n, m));
        }
    }
    public static int  get0(int n,int m) {
        {
            int c2=0,c5=0;
            for(int i=n;i>=n-m+1;i--)
            {
                int x=i;
                while(x%2==0) { c2++;x/=2; }
                while(x%5==0) { c5++;x/=5; }
            }

            for(int i=m;i>0;i--)
            {
                int x=i;
                while(x%2==0) { c2--;x/=2; }
                while(x%5==0) { c5--;x/=5; }
            }
            return Math.min(c2,c5);
        }
    }
}
class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String next() throws IOException{
        while(!st.hasMoreElements()) {
            st = new StringTokenizer(br.readLine());
        }
        return st.nextToken();
    }
    int nextInt() throws IOException{
        return Integer.parseInt(next());
    }
    long nextLong() throws IOException{
        return Long.parseLong(next());
    }
    Double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
}